﻿<Controls:ChildWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    xmlns:ViewModels="clr-namespace:Spenta.StreetCare.Silverlight.MVVM.ViewModels" 
    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:UserControls="clr-namespace:Spenta.StreetCare.Silverlight.UserControls" 
    xmlns:local="clr-namespace:Spenta.StreetCare.Silverlight.MVVM.Validations" 
    x:Class="Spenta.StreetCare.Silverlight.UserControls.ReportDetailChildControl"
    mc:Ignorable="d" d:DesignHeight="600" Width="500">

    <Controls:ChildWindow.Resources>
        <ViewModels:ReportDetailViewModel x:Key="ReportDetailViewModel" />
    </Controls:ChildWindow.Resources>

    <Controls:ChildWindow.Template>
        <StaticResource ResourceKey="PopUpWindowStyle"/>
    </Controls:ChildWindow.Template>

    <Controls:ChildWindow.Title>
        <TextBlock Text="{Binding Report.Category.CategoryTitle, Source={StaticResource ReportDetailViewModel}}" />
    </Controls:ChildWindow.Title>

    <Grid x:Name="LayoutRoot" DataContext="{StaticResource ReportDetailViewModel}" d:DataContext="{d:DesignData /SampleData/ReportDetailViewModelSampleData.xaml}">
        <ScrollViewer VerticalScrollBarVisibility="Auto" BorderThickness="0" Margin="8,0,0,37">
            <StackPanel>
                <StackPanel>
                    <Grid Margin="10,10,10,5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal">
                            <dataInput:Label Content="{Binding Literals.ReportedBy}" Margin="0,0,10,0" Style="{StaticResource FormCaption}" />
                            <dataInput:Label Content="{Binding Report.User.UserNickname}" Style="{StaticResource FormValue}" />
                        </StackPanel>
                        <StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal">
                            <dataInput:Label Content="{Binding Literals.Date}" Margin="0,0,10,0" Style="{StaticResource FormCaption}" />
                            <dataInput:Label Content="{Binding Report.ReportWhen, ConverterParameter=dd/MM/yyyy, Converter={StaticResource DateConverter}}" Style="{StaticResource FormValue}" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1">
                            <dataInput:Label Content="{Binding Literals.Status}" Margin="0,0,10,0" Style="{StaticResource FormCaption}" />
                            <dataInput:Label Content="{Binding Report.Status.StatusTitle}" Style="{StaticResource FormValue}" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1">
                            <dataInput:Label Content="{Binding Literals.LastChange}" Margin="0,0,10,0" Style="{StaticResource FormCaption}" />
                            <dataInput:Label Content="{Binding Report.ReportStatusWhen, ConverterParameter=dd/MM/yyyy, Converter={StaticResource DateConverter}}" Style="{StaticResource FormValue}" />
                        </StackPanel>
                    </Grid>
					
                    <ContentControl  Template="{StaticResource SeparatorReport}"/>

                	<StackPanel Margin="10,0,10,10">
                        <dataInput:Label Content="{Binding Literals.Description}" Style="{StaticResource FormCaption}" Padding="0" />
                		<dataInput:Label Content="{Binding Report.ReportTitle}" Style="{StaticResource FormValue}" Padding="0" />
                		<ContentControl  Template="{StaticResource SeparatorReport}"/>
                		<Controls:TabControl Height="200">
                            <Controls:TabItem Header="{Binding Literals.Location}">
                				<Grid Background="#FFE5E5E5">
                                    <m:Map x:Name="map" CredentialsProvider="{Binding Customer.CustomerMapCredentials}" IsEnabled="False" LogoVisibility="Collapsed" NavigationVisibility="Collapsed" ZoomLevel="15" Margin="1">
                                        <m:Map.Mode>
                                            <m:AerialMode Labels="True" AnimationLevel="None" />
                                        </m:Map.Mode>
                                        <m:Pushpin Location="{Binding Report.ReportMapLocation}" Background="{Binding Report.Category.CategoryColor, Converter={StaticResource PushpinTypeBrushConverter}}">
                                            <Image Source="{Binding Report.Category.CategoryImageUrl}" />
                                        </m:Pushpin>
                					</m:Map>
                				</Grid>
                			</Controls:TabItem>
                            <Controls:TabItem Header="{Binding Literals.Pictures}">
                				<StackPanel Background="#FFE5E5E5" Orientation="Horizontal">
                                    <ContentControl Template="{StaticResource UnfixedImage}" Content="{Binding Report.ReportImageUrl}" Width="141" Height="110" Visibility="{Binding Report.ReportImageVisible, Converter={StaticResource VisibilityToBoolConverter}}"/>
                                    <ContentControl Template="{StaticResource FixedImage}" Content="{Binding Report.ReportFixedImageUrl}" Margin="15,0,0,0" Width="141" Height="110" Visibility="{Binding Report.ReportFixedImageVisible, Converter={StaticResource VisibilityToBoolConverter}}"/>
                                    
                                </StackPanel>
                			</Controls:TabItem>
                		</Controls:TabControl>


                        <dataInput:Label Content="{Binding Literals.Comments}" Margin="0,10,0,0" Style="{StaticResource FormCaption}" />
                		<ItemsControl ItemsSource="{Binding Report.Comments}">
                			<ItemsControl.ItemTemplate>
                				<DataTemplate>
                					<StackPanel>
                						<StackPanel HorizontalAlignment="Stretch" Margin="0,3,0,0" VerticalAlignment="Top" Orientation="Horizontal">
                							<Border Style="{StaticResource BorderUserCommentStyle}">
                								<Image Source="{Binding User.UserImageUrl}" Stretch="Fill" />
                							</Border>
                							

                							<StackPanel HorizontalAlignment="Left" Height="50">
                								<StackPanel Width="379" Orientation="Horizontal">
                									<dataInput:Label Content="{Binding User.UserNickname}" VerticalAlignment="Top"  />
                									<dataInput:Label Content="{Binding CommentWhen, Converter={StaticResource DateConverter}}" Margin="5,0"  />
                									<dataInput:Label Content="{Binding Literals.Said, Source={StaticResource ReportDetailViewModel}}"  />
                								</StackPanel>
                								<TextBlock Text="{Binding CommentText}" TextWrapping="Wrap" Margin="0" />
                								<StackPanel Width="379" Orientation="Horizontal">
                									<dataInput:Label Content="{Binding Literals.Rate, Source={StaticResource ReportDetailViewModel}}" VerticalAlignment="Center" />
                									<inputToolkit:Rating Style="{StaticResource RatingStarsStyle}" ItemContainerStyle="{StaticResource RatingStyle}" Value="{Binding CommentRating}" ItemCount="5" HorizontalAlignment="Center" BorderBrush="Black" VerticalAlignment="Top" Background="Transparent" SelectionMode="Continuous" IsEnabled="False" RenderTransformOrigin="0.5,0.5">
                										<inputToolkit:Rating.RenderTransform>
                											<TransformGroup>
                												<ScaleTransform ScaleX="0.75" ScaleY="0.75"/>
                												<SkewTransform/>
                												<RotateTransform/>
                												<TranslateTransform/>
                											</TransformGroup>
                										</inputToolkit:Rating.RenderTransform>
                									</inputToolkit:Rating>
                								</StackPanel>
                							</StackPanel>

                						</StackPanel>
                						<ContentControl  Template="{StaticResource SeparatorReport}" Margin="0,5,0,0"/>
                					</StackPanel>
                				</DataTemplate>
                			</ItemsControl.ItemTemplate>
                		</ItemsControl>
                       
                			
                            <StackPanel Margin="0" local:ValidationScope.ValidationScope="{Binding CommentValidationScope}"  Visibility="{Binding Authenticated, Converter={StaticResource VisibilityToBoolConverter}}">
                                <dataInput:Label Content="{Binding Literals.RateThisIssue}" Margin="0,10,0,0" Style="{StaticResource FormCaption}"  />
                				<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                    <inputToolkit:Rating Style="{StaticResource RatingStarsStyle}" ItemContainerStyle="{StaticResource RatingStyle}" Value="{Binding Comment.CommentRating, Mode=TwoWay}" ItemCount="5" BorderBrush="Black" Background="Transparent" SelectionMode="Continuous" Margin="10" />              						
                				</StackPanel>
                                <dataInput:Label Content="{Binding Literals.WouldYouLikeToMakeAComment}" Margin="0,10,0,5" Style="{StaticResource FormCaption}"  />
                                <TextBox Text="{Binding Comment.CommentText, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" local:ValidationScope.ValidateBoundProperty="Text" TextWrapping="Wrap" Style="{StaticResource TextBoxInputWizard}" MinHeight="70" Margin="0,0,0,10" />
                                <Button Content="{Binding Literals.SendMyComment}" Padding="20,0,20,0" Style="{StaticResource WizardButton}" Command="{Binding CreateCommentCommand}" HorizontalAlignment="Center" VerticalAlignment="Top" />
                			</StackPanel>
                	</StackPanel>
                </StackPanel>
            </StackPanel>
        </ScrollViewer>

        <UserControls:ChildWindowWaitUserControl Visibility="{Binding WaitingVisible, Converter={StaticResource VisibilityToBoolConverter}}"/>

    </Grid>
</Controls:ChildWindow>
